package com.googlecode.monitoria.client.services;

import com.google.gwt.user.client.rpc.RemoteService;
import com.googlecode.monitoria.client.to.UserTO;

/**
 * System available operations. These operations can be divided into three main categories
 * according to the user level of privilege:
 * <br>
 * <ol>
 * <li>Administration operations;</li>
 * <li>Assistants operations;</li>
 * <li>Students operations.</li>
 * </ol>
 * @author Ricardo Araújo Santos - ricardo@lsd.ufcg.edu.br
 */
public interface MonitoriaService extends RemoteService {
	
	/**
	 * Checks if this is the first time this application is executed.
	 * @return <code>true</code> in affirmative case and <code>false</code> otherwise.
	 */
	Boolean isFirstRun();
	
	/**
	 * Register the full privileged user for administration purposes.
	 * @param password The administrator plain-text password.
	 * @throws Exception 
	 */
	void registerAdmin(String password) throws Exception;
	
	/**
	 * Attempts to log the user in.
	 * 
	 * @param name User name
	 * @param password Password
	 * @return A {@link UserTO} if the log in could be done or null otherwise.
	 */
	public UserTO login(String name, String password);
	
	/**
	 * @return The user who is currently logged in.
	 */
	UserTO getLoggedUser();
	
	/**
	 * Logs user out.
	 * @return <code>true</code> if there was a opened session and <code>false</code> otherwise.
	 */
	boolean logout();
	
	/**
	 * Creates a new teacher in the system. The new teacher contains the information set in the given
	 * {@link UserTO} parameter.
	 * @param name New teacher's name.
	 * @param password New teacher's plain-text password.s 
	 * @return The new information in a {@link UserTO} object. 
	 * @throws Exception Thrown when there is already a teacher with the same login in the database.
	 */
	UserTO createTeacher(String name, String password) throws Exception;
}
